#pragma once

#include "IMemory.h"

namespace VirtualHardware
{
	public ref class RAM : IMemory
	{
	public:
		property UInt32 default[UInt32]
		{
			virtual UInt32 get(UInt32 i)
			{
				return GetValueAt(i);
			}
			virtual void set(UInt32 i, UInt32 value)
			{
				SetValueAt(i, value);
			}
		}

		property UInt32 FinalAddress
		{
			UInt32 get()
			{
				return finalAddress;
			}
		}

		property int RamSize
		{
			int get()
			{
				return finalAddress + 1;
			}
		}

		RAM(UInt32 memorySize);

		virtual inline UInt32 GetValueAt(UInt32 i);
		virtual inline void SetValueAt(UInt32 i, UInt32 value);
		inline Byte GetByteAt(UInt32 i);
		inline void SetByteAt(UInt32 i, Byte value);

		Boolean LoadIntoMemory(array<UInt32>^ values, UInt32 startAddress);

	private:
		UInt32 finalAddress;

		array<Byte>^ data;
	};
}
